<!-- 修改单条数据 -->
<template>
  <div>
    <my-dialog width="1000px" @cancel="onCloseDialog" @confirm="submitForm" title="编辑 - - 阿托品注射液" :visible.sync="visible"
      append-to-body>
      <el-form ref="form-data" :model="form" :rules="rules" label-width="130px">
        <el-form-item label="特殊资源">
          <el-radio-group v-model="form.resource">
            <el-radio label="单次"></el-radio>
            <el-radio label="持续"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="编码" style="width: 500px;" prop="patientSurgeryId">
          <el-input v-model="form.patientSurgeryId" placeholder="请输入编码" />
        </el-form-item>
        <el-form-item style="width: 500px;" label="名称" prop="patientSurgeryId">
          <el-input v-model="form.patientSurgeryId" placeholder="阿托品注射液" />
        </el-form-item>
        <el-form-item style="width: 800px;" label="给药方式" prop="patientSurgeryId">
          <el-select v-model="form.region" placeholder="请选择给药方式">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item style="width: 500px;" label="给药原因" prop="patientSurgeryId">
          <el-input v-model="form.patientSurgeryId" placeholder="请输入给药原因" />
        </el-form-item>
        <el-form-item style="width: 800px;" label="计量" prop="patientSurgeryId">
          <el-input style="width: 300px;" v-model="form.patientSurgeryId" placeholder="请输入给药原因" />
          /
          <el-select style="width: 80px;" v-model="form.region" placeholder="ml">
            <el-option label="mg" value="shanghai"></el-option>
            <el-option label="ml" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <br />
        <el-form-item style="width: 800px;" label="流速浓度" prop="patientSurgeryId">
          <el-input style="width: 150px;" type="number" v-model="form.patientSurgeryId" placeholder="流速浓度" />
          &nbsp;
          <el-select style="width: 80px;" v-model="form.region" placeholder="ml">
            <el-option label="mg" value="shanghai"></el-option>
            <el-option label="ml" value="beijing"></el-option>
          </el-select>
          &nbsp;
          <el-date-picker style="width: 160px;" v-model="value1" type="datetime" placeholder="选择日期时间">
          </el-date-picker>
          &nbsp;
          <el-button>删除</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" plain>新增流速</el-button>
        </el-form-item>
      </el-form>
    </my-dialog>
  </div>
</template>
<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    },
  },
  data() {
    return {
      // 表单参数
      id: null,
      form: {
        id: null,
        patientSurgeryId: null,
      },
      // 表单校验
      rules: {
        patientSurgeryId: [
          { required: true, message: '不能为空', trigger: 'blur' },
        ],
      }
    }

  },
  methods: {
    init(id) {
      if (id) {
        this.id = id
      }
    },
    // 弹窗关闭的回调
    onCloseDialog() {
      this.$emit('update:visible', false)
    },
    /** 提交按钮 */
    submitForm() {
      console.log(this.form);
      this.$refs["form-data"].validate(valid => {
        if (valid) {
          // 编辑
          if (this.id) {
            this.$modal.msgSuccess("修改成功");
            // 刷新列表
            this.getPage();
            this.onCloseDialog()
          } else {
            // 新增
            this.$modal.msgSuccess("新增成功");
            // 刷新列表
            this.getPage();
            this.onCloseDialog()
          }
        }
      });
    },
  }
}
</script>
<style lang="scss" scoped></style>